package rollercoaster.commons;

import java.util.ArrayList;
import java.util.List;

import javax.media.opengl.GL2ES2;

public class Node {
	
	private List<Model> models=new ArrayList<Model>();
	private float[] transformMatrix;
	private int[] shaderAttributes;

	public Node(List<Model> models) {
		super();
		this.models = models;
	}

	public List<Model> getModels() {
		return models;
	}

	public void setModels(List<Model> models) {
		this.models = models;
	}
	
	public float[] getTransformMatrix() {
		return transformMatrix;
	}

	public void setTransformMatrix(float[] transformMatrix) {
		this.transformMatrix = transformMatrix;
	}
	
	public void setShaderAttributes(int[] shaderAttributes){
		this.shaderAttributes=shaderAttributes;
		for (Model model : models) {
			model.setShaderAtrributes(shaderAttributes);
		}
	}

	public void drawNode(GL2ES2 gl){
		gl.glUniformMatrix4fv(shaderAttributes[4], 1, false, transformMatrix, 0);
		for (Model model : models) {
			model.draw(gl);
		}
	}
	
}
